package calculator;

public class Stack
{
	private double[]	stack;
	int					stackPointer;
	int					groesse	= 100;

	public Stack()
	{
		stackPointer = -1;

		stack = new double[groesse];
	}

	public void push(Double element)
	{
		stackPointer++;
		if (stackPointer == stack.length)
		{
			double[] tmpArray = new double[stack.length + (groesse / 2)];
			System.arraycopy(stack, 0, tmpArray, 0, stack.length);
			stack = tmpArray;

		}
		stack[stackPointer] = element;

	}

	public Double pop()
	{
		// stackPointer--;
		if (stackPointer < 0)
		{
			return null;
		}
		Double oberesElement = stack[stackPointer];
		stack[stackPointer] = 0.0;
		stackPointer--;
		return oberesElement;

	}
}
// int lastIndex = stack.length - 1;
// Double oberesElement = stack[lastIndex];
// stack.pop[lastIndex]; // weil in stack doubles sein koennen
// return oberesElement;

// private List<Double> stack;
//
// public Stack()
// {
// this.stack = new ArrayList<String>();
// }
//
// public void push(String element)
// {
// this.stack.add(element);
// }
//
// public String pop()
// {
// if(this.stack.size() == 0)
// {
// return null;
// }
//		
//		
// int lastIndex = this.stack.size() - 1;
// String oberesElement = this.stack.get(lastIndex);
// this.stack.remove(lastIndex); // weil in stack doubles sien koennen
// return oberesElement;
// }
//
// public String toString()
// {
// return this.stack.toString();
// }
//
// }
